 byte data[12];  //For holding the ID we receive
 int val = 0, greenon = 0xFF, greenoff = 0xFE, redon = 0xFD, redoff = 0xFC;
 int faston = 0xFB, readUID = 0xFA, transon = 0xF8, transoff = 0xF7;
 byte transmitter_off[9] = {0x01,0x09,0x00,0x03,0x04,0x49,0x00,0x46,0xB9};
 byte transmitter_on[8]  = {0x01,0x08,0x00,0x03,0x04,0x48,0x46,0xB9};
 byte pass_read_single[13] = {0x01,0x0D,0x00,0x03,0x04,0x45,0x03,0x20,0x01,0x12,0x1B,0x65,0x9A};

void setup()
 {
   int ii=0;
   // Start serial port 19200 bps
   Serial.begin(19200);
   Serial.flush();
 //  Serial.write(0xFF);
   // Setting Single Block Read Mode
   // command: 01 0D 00 03 04 45 03 20 01 12 1B 65 9A
   Serial.write(redon);
   delay(2000);
   Serial.write(redoff);
   delay(2000);
   Serial.write(greenon);
   delay(2000);
   for(ii=0; ii<13; ii++){
     Serial.write(pass_read_single[ii]);
   }
   delay(2000);
   while(Serial.available()>0)
   Serial.flush();
   {
     val = Serial.read();
     Serial.print(val,HEX);
   }
   Serial.println();
   Serial.println("RFID module started in Auto Read Mode, Waiting for Card...");
   Serial.flush();
 }

 void loop()
{
  Serial.flush();
  Serial.write(0xFA);  //Read UID
  delay(100);
  val = Serial.read();
  while (val != 0xff)
   {  //On Successful read, first byte will always be 0xFF
      val = Serial.read();
//      delay(100);
   }
  while(Serial.available()>0){
    val = Serial.read();
    Serial.print(val,HEX);
//    delay(100);
  }
   
   //we already read the header (0xff)
//   data[0] = Serial.read();              // reserved
//   data[1] = Serial.read();              // length
//   data[2] = Serial.read();              // command (indicates tag data)
//   data[3] = Serial.read();    // we read data 1
//   data[4] = Serial.read();    // we read data 2
//   data[5] = Serial.read();    // we read data 3
//   data[6] = Serial.read();    // we read data 4
//   data[7] = Serial.read();    // we read data 5
//   data[8] = Serial.read();
//   data[9] = Serial.read();              // checksum
//   data[10] = Serial.read();
//   data[11] = Serial.read();
   
//   // Indentify RFID Card
//   boolean j_card = true;
//   boolean d_card = true;
//   Serial.print("Card found - Code: ");
//   for (int i=0; i<11; i++)
//   {
//     //if (data[i] < 16) Serial.print("0");
//     Serial.print(data[i], HEX);
//      
//     //cross-check
//     if (data[i] != jeremy[i]) j_card = false;
//     if (data[i] != david[i]) d_card = false;
//   }
//   Serial.println();
//   
//   if (j_card) Serial.println("Hello Jeremy!");
//   else if (d_card) Serial.println("Hello David!");
//   else Serial.println("Not Recognized!  Get out of Here!");
//   Serial.println();

}

